var aboutBtn = document.getElementById('about');
var timeBtn = document.getElementById('time');
var hotBtn = document.getElementById('hot');
var friendBtn = document.getElementById('friend');
onload = function() {
    init();
};
var init = function()
{
    aboutBtn.onclick = function(e) {
        keyword = searchblock.value;
        searchEventToServlet();
      
    };
    
    timeBtn.onclick = function(e) {
        sort_by = "time";
        searchEventToServlet();
        $(this).css('color','#fff');
        $(hotBtn).css('color','#000');
        $(friendBtn).css('color','#000');
    };
    
    hotBtn.onclick = function(e) {
        sort_by = "hot";
        searchEventToServlet();
        $(this).css('color','#fff');
        $(timeBtn).css('color','#000');
        $(friendBtn).css('color','#000');
    };
    
    friendBtn.onclick = function(e) {
        sort_by = "friend";
        searchEventToServlet();
        $(this).css('color','#fff');
        $(timeBtn).css('color','#000');
        $(hotBtn).css('color','#000');
    };
    searchblock.onsubmit = function(e) {
        if(e.keyCode == 13) // enter pressed
        {
            keyword = searchblock.value;
            console.log('searching:'+keyword);
            searchEventToServlet();
        }
    }; 
    $('.tag').css("cursor","pointer");
    $('.tag').click(function()
    {
       keyword = $(this).text();
       console.log(keyword);
       searchEventToServlet(); 
    });
    
}
